import React from 'react'

interface Props {

}

const Mysort = (props: Props) => {
    var arr = [1, 2, 2, 2, 3, 4, 5]
    var set = new Set(arr)
    // console.log(set)
    // for (var key in set) {
    //     // console.log(1111);
        
    //  console.log(key);
     
        
    // }
   var aa:number[]=[]
 for (let item of set) {
    // console.log(item);
 
    aa.push(item)

 }

    var newArr = [2, 1, 4, 3]
    var arr = [2, 1, 4, 3]
    const difference = (arr: number[]): number[] => {
        return arr.sort()
    }
    const getSum = (arr: number[]) => {
        return arr.reduce((i, j) => {
            return i + j
        })
    }
     console.log("去重值后求和"+getSum(aa))
    return (
        <div>
            原来的数组是：{newArr}
            排序后的数组是：{difference(arr)}
            求和是：{getSum(arr)}
        </div>
    )
}

export default Mysort
